In this notebook, we are using the tmb_genomic.tsv file
generated from the 01-preprocess-data.Rmd script.
suppressPackageStartupMessages({
library(tidyverse)
})
# Detect the ".git" folder. This will be in the project root directory.
# Use this as the root directory to ensure proper sourcing of functions
# no matter where this is called from.
root_dir <- rprojroot::find_root(rprojroot::has_dir(".git"))
scratch_dir <- file.path(root_dir, "scratch")
analysis_dir <- file.path(root_dir, "analyses", "tmb-vaf-longitudinal")
input_dir <- file.path(analysis_dir, "input")
# Input files
tmb_genomic_file <- file.path(scratch_dir, "tmb_genomic.tsv")
tumor_descriptor_color_palette_file <- file.path(root_dir, "figures", "palettes", "tumor_descriptor_color_palette.tsv")
# File path to plots directory
plots_dir <-
file.path(analysis_dir, "plots")
if (!dir.exists(plots_dir)) {
dir.create(plots_dir)
}
source(paste0(analysis_dir, "/util/function-create-barplot.R"))
source(paste0(root_dir, "/figures/scripts/theme.R"))
# Read and process tmb_genomic file
tmb_genomic_all <- readr::read_tsv(tmb_genomic_file, guess_max = 100000, show_col_types = FALSE)
# Are there any samples with both WGS and WXS?
tmb_genomic_all %>%
unique() %>%
arrange(Kids_First_Participant_ID, experimental_strategy) %>%
group_by(Kids_First_Participant_ID) %>%
dplyr::summarise(experimental_strategy_sum = str_c(experimental_strategy, collapse = ";"))
# Yes, they are, so let's remove these from downstream analyses.
tmb_genomic <- tmb_genomic_all %>%
filter(!experimental_strategy == "WXS")
# Read color palette
tumor_descriptor_color_palette <- readr::read_tsv(tumor_descriptor_color_palette_file, guess_max = 100000, show_col_types = FALSE)
We will explore TMB per Kids_First_Participant_ID over
time by creating stacked barplots.
# Define parameters for function
ylim <- 360
tmb_df <- tmb_genomic
# Run function
fname <- paste0(plots_dir, "/", "TMB-genomic.pdf")
print(fname)
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/TMB-genomic.pdf"
p <- create_stacked_barplot(tmb_df = tmb_df, ylim = ylim)
pdf(file = fname, width = 15, height = 6)
print(p)
dev.off()
quartz_off_screen
2
Attention: Low TMB defined as ≤5 mutations/Mb, intermediate TMB defined as >5 and ≤20/Mb, high TMB defined as >20 and ≤50 Mb, and very high TMB defined as >50 mutations/Mb.
Here, we notice that there are samples with high TMB (hyper-mutant samples). Next, we will exclude these samples (threshold >= 50) from downstream analysis. Attention is needed in cases with high number of mutations in only one timepoint as this will lead to un-matched longitudinal samples. We will also remove those so we always have matched longitudinal samples.
We will explore TMB per cancer group over time by creating stacked barplots. We will plot based on cancer groups presenting with the highest number of samples (High- and Low-grade gliomas) vesrus any other cancer groups.
plots_panel <- multiplot(plotlist = plot_lst, ncol = 3, widths = c(1.5,2))
[1] 3
[1] 1.5 2.0
Here, we want to explore the number of mutations
(mutation_count column) per timepoint and biospecimen
sample per patient case by creating barplots.
samples <- unique(as.character(tmb_genomic_filter$Kids_First_Participant_ID))
print(samples)
[1] "PT_00G007DM" "PT_02J5CWN5" "PT_1H2REHT2" "PT_1ZAWNGWT" "PT_25Z2NX27" "PT_2ECVKTTQ" "PT_2FVTD0WR"
[8] "PT_2YT37G8P" "PT_37B5JRP1" "PT_3R0P995B" "PT_3T3VGWC6" "PT_3VCS1PPF" "PT_7M2PGCBV" "PT_82MX6J77"
[15] "PT_89XRZBSG" "PT_8GN3TQRM" "PT_962TCBVR" "PT_98QMQZY7" "PT_99S5BPE3" "PT_9PJR0ZK7" "PT_9S6WMQ92"
[22] "PT_AQWDQW27" "PT_CXT81GRM" "PT_DFQAH7RS" "PT_ESHACWF6" "PT_FN4GEEFR" "PT_HFQNKP5X" "PT_HJMP6PH2"
[29] "PT_JNEV57VK" "PT_JP1FDKN9" "PT_JSFBMK5V" "PT_K8ZV7APT" "PT_KMHGNCNR" "PT_MDWPRDBT" "PT_MNSEJCDM"
[36] "PT_N8W26H19" "PT_NPETR8RY" "PT_PFA762TK" "PT_PR4YBBH3" "PT_QH9H491G" "PT_RJ1TJ2KH" "PT_S2SQJVGK"
[43] "PT_S4YNE17X" "PT_T2M1338J" "PT_TKWTTRQ7" "PT_W6AWJJK7" "PT_WP871F5S" "PT_XA98HG1C" "PT_XHYBZKCX"
[50] "PT_XTVQB9S4" "PT_YGN06RPZ" "PT_Z4GS3ZQQ" "PT_ZMKMKCFQ" "PT_ZZRBX5JT"
for (i in seq_along(samples)) {
print(i)
tmb_sub <- tmb_genomic_filter %>%
filter(Kids_First_Participant_ID == samples[i])
# Define parameters for function
ylim <- 260
# Run function
fname <- paste0(plots_dir, "/", samples[i], "-TMB-barplot.pdf")
print(fname)
p <- create_barplot_sample(tmb_df = tmb_sub,
ylim = ylim,
sid = samples[i])
pdf(file = fname, width = 5, height = 4)
print(p)
dev.off()
}
[1] 1
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_00G007DM-TMB-barplot.pdf"
[1] 2
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_02J5CWN5-TMB-barplot.pdf"
[1] 3
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_1H2REHT2-TMB-barplot.pdf"
[1] 4
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_1ZAWNGWT-TMB-barplot.pdf"
[1] 5
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_25Z2NX27-TMB-barplot.pdf"
[1] 6
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_2ECVKTTQ-TMB-barplot.pdf"
[1] 7
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_2FVTD0WR-TMB-barplot.pdf"
[1] 8
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_2YT37G8P-TMB-barplot.pdf"
[1] 9
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_37B5JRP1-TMB-barplot.pdf"
[1] 10
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_3R0P995B-TMB-barplot.pdf"
[1] 11
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_3T3VGWC6-TMB-barplot.pdf"
[1] 12
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_3VCS1PPF-TMB-barplot.pdf"
[1] 13
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_7M2PGCBV-TMB-barplot.pdf"
[1] 14
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_82MX6J77-TMB-barplot.pdf"
[1] 15
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_89XRZBSG-TMB-barplot.pdf"
[1] 16
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_8GN3TQRM-TMB-barplot.pdf"
[1] 17
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_962TCBVR-TMB-barplot.pdf"
[1] 18
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_98QMQZY7-TMB-barplot.pdf"
[1] 19
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_99S5BPE3-TMB-barplot.pdf"
[1] 20
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_9PJR0ZK7-TMB-barplot.pdf"
[1] 21
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_9S6WMQ92-TMB-barplot.pdf"
[1] 22
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_AQWDQW27-TMB-barplot.pdf"
[1] 23
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_CXT81GRM-TMB-barplot.pdf"
[1] 24
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_DFQAH7RS-TMB-barplot.pdf"
[1] 25
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_ESHACWF6-TMB-barplot.pdf"
[1] 26
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_FN4GEEFR-TMB-barplot.pdf"
[1] 27
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_HFQNKP5X-TMB-barplot.pdf"
[1] 28
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_HJMP6PH2-TMB-barplot.pdf"
[1] 29
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_JNEV57VK-TMB-barplot.pdf"
[1] 30
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_JP1FDKN9-TMB-barplot.pdf"
[1] 31
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_JSFBMK5V-TMB-barplot.pdf"
[1] 32
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_K8ZV7APT-TMB-barplot.pdf"
[1] 33
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_KMHGNCNR-TMB-barplot.pdf"
[1] 34
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_MDWPRDBT-TMB-barplot.pdf"
[1] 35
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_MNSEJCDM-TMB-barplot.pdf"
[1] 36
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_N8W26H19-TMB-barplot.pdf"
[1] 37
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_NPETR8RY-TMB-barplot.pdf"
[1] 38
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_PFA762TK-TMB-barplot.pdf"
[1] 39
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_PR4YBBH3-TMB-barplot.pdf"
[1] 40
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_QH9H491G-TMB-barplot.pdf"
[1] 41
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_RJ1TJ2KH-TMB-barplot.pdf"
[1] 42
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_S2SQJVGK-TMB-barplot.pdf"
[1] 43
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_S4YNE17X-TMB-barplot.pdf"
[1] 44
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_T2M1338J-TMB-barplot.pdf"
[1] 45
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_TKWTTRQ7-TMB-barplot.pdf"
[1] 46
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_W6AWJJK7-TMB-barplot.pdf"
[1] 47
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_WP871F5S-TMB-barplot.pdf"
[1] 48
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_XA98HG1C-TMB-barplot.pdf"
[1] 49
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_XHYBZKCX-TMB-barplot.pdf"
[1] 50
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_XTVQB9S4-TMB-barplot.pdf"
[1] 51
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_YGN06RPZ-TMB-barplot.pdf"
[1] 52
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_Z4GS3ZQQ-TMB-barplot.pdf"
[1] 53
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_ZMKMKCFQ-TMB-barplot.pdf"
[1] 54
[1] "/Users/chronia/CHOP/GitHub/pbta-tumor-evolution/analyses/tmb-vaf-longitudinal/plots/PT_ZZRBX5JT-TMB-barplot.pdf"
sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggpubr_0.6.0 gridExtra_2.3 cowplot_1.1.1 ggthemes_4.2.4 Rmisc_1.5.1 plyr_1.8.8
[7] lattice_0.21-8 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2 purrr_1.0.1
[13] readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2 tidyverse_2.0.0
loaded via a namespace (and not attached):
[1] tidyselect_1.2.0 xfun_0.39 bslib_0.5.0 carData_3.0-5 colorspace_2.1-0 vctrs_0.6.3
[7] generics_0.1.3 htmltools_0.5.5 yaml_2.3.7 utf8_1.2.3 rlang_1.1.1 pillar_1.9.0
[13] jquerylib_0.1.4 glue_1.6.2 withr_2.5.0 bit64_4.0.5 lifecycle_1.0.3 ggsignif_0.6.4
[19] munsell_0.5.0 gtable_0.3.3 evaluate_0.21 labeling_0.4.2 knitr_1.43 tzdb_0.4.0
[25] fastmap_1.1.1 parallel_4.2.3 fansi_1.0.4 broom_1.0.5 Rcpp_1.0.11 backports_1.4.1
[31] scales_1.2.1 cachem_1.0.8 vroom_1.6.3 jsonlite_1.8.7 abind_1.4-5 farver_2.1.1
[37] bit_4.0.5 hms_1.1.3 digest_0.6.33 stringi_1.7.12 rstatix_0.7.2 rprojroot_2.0.3
[43] cli_3.6.1 tools_4.2.3 magrittr_2.0.3 sass_0.4.7 car_3.1-2 crayon_1.5.2
[49] pkgconfig_2.0.3 timechange_0.2.0 rmarkdown_2.23 rstudioapi_0.15.0 R6_2.5.1 compiler_4.2.3